package com.itlong.cloud.enumerate;

import lombok.Getter;

/**
 * <desc>
 * 电梯正背面类型.
 * </desc>
 *
 * @createDate 2017-10-12
 */
public enum LiftDoorTypeEnum {

    BACK_DOOR("背门",0),
    FRONT_DOOR("正门",1);

    @Getter
    private Integer type;  //正背门类型

    @Getter
    private String description;  //正背门类型描述（名称）


    /**
     * <desc>
     * 构造函数.
     * </desc>
     *
     * @param type        正背门类型
     * @param description 正背门类型描述（名称）
     * @author LewisLouis
     * @createDate 2017-10-12
     */
    LiftDoorTypeEnum(String description, Integer type) {
        this.description = description;
        this.type = type;
    }


    /**
     * <desc>
     * 根据正背门类型获取描述（名称）.
     * </desc>
     *
     * @param type 正背门类型
     * @return 正背门类型描述（名称）
     * @author LewisLouis
     * @createDate 2017-10-12
     */
    public static String getDescription(int type) {
        LiftDoorTypeEnum[] types = LiftDoorTypeEnum.values();
        for (LiftDoorTypeEnum limitCategory : types) {
            if (limitCategory.getType() == type) {
                return limitCategory.getDescription();
            }
        }
        return "";
    }


    /**
     * <desc>
     * 根据正背门描述（名称）获取类型.
     * </desc>
     *
     * @param description 正背门类型描述（名称）
     * @return 正背门类型
     * @author LewisLouis
     * @createDate 2017-10-12
     */
    public static Integer getType(String description) {
        LiftDoorTypeEnum[] types = LiftDoorTypeEnum.values();
        for (LiftDoorTypeEnum limitCategory : types) {
            if (limitCategory.getDescription().equalsIgnoreCase(description)) {
                return limitCategory.getType();
            }
        }
        return FRONT_DOOR.getType();
    }
}
